package model.inventory;

import java.util.HashMap;
import java.util.Map;

import org.json.simple.JSONObject;

public class FieldFormatMapper {
	private Map<String, JSONObject> map;

	public FieldFormatMapper() {
		map = new HashMap<String, JSONObject>();
	}

	public void put(String fieldName, JSONObject obj) {
		map.put(fieldName, obj);
	}
	
	public JSONObject get(String fieldName) {
		if(map.containsKey(fieldName)) {
			return map.get(fieldName);
		} else {
			// return a non-playable content type instead of null
			return new JSONObject();
		}
	}
	
	public void removeMapping(String fieldName) {
		this.map.remove(fieldName);
	}
	
	public int size() {
		return this.map.size();
	}
	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		for(String key: this.map.keySet()) {
			sb.append(key + ": " + map.get(key)).append("\n");
		}
		return sb.toString();
	}
}
